<!DOCTYPE html>
<html class="bg-white">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>修改分类</title>
    <link rel="stylesheet" href="/static/assets/libs/layui/css/layui.css" />
    <link rel="stylesheet" href="/static/assets/module/admin.css?v=312" />
</head>

<body>
    <form class="layui-form model-form" id="form-psw">
        <input type="hidden" name="Id" class="layui-input" value="{$sort['Id']}" />
        <div class="layui-form-item">
            <label class="layui-form-label">分类名称:</label>
            <div class="layui-input-block">
                <input type="text" name="name" placeholder="请输入分类名称" class="layui-input" lay-verType="tips"
                    lay-verify="required" required value="{$sort['name']}" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分类别名:</label>
            <div class="layui-input-block">
                <input type="text" name="alias" placeholder="请输入分类别名" class="layui-input" lay-verType="tips"
                    lay-verify="required" required value="{$sort['alias']}" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">关键词:</label>
            <div class="layui-input-block">
                <input type="text" name="key" placeholder="请输入分类关键词" class="layui-input" lay-verType="tips"
                    lay-verify="required" required value="{$sort['key']}" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分类介绍:</label>
            <div class="layui-input-block">
                <input type="text" name="desc" placeholder="请输入分类介绍" class="layui-input" lay-verType="tips"
                    lay-verify="required" required value="{$sort['desc']}" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">类型:</label>
            <div class="layui-input-block">
                <input type="radio" name="type" value="0" title="默认规则" {eq name="$sort['type']" value="0"}checked{/eq}>
                <input type="radio" name="type" value="1" title="完全免费" {eq name="$sort['type']" value="1"}checked{/eq}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">菜单:</label>
            <div class="layui-input-block">
                <input type="radio" name="is_menu" value="0" title="不显示" {eq name="$sort['is_menu']" value="0"}checked{/eq}>
                <input type="radio" name="is_menu" value="1" title="显示" {eq name="$sort['is_menu']" value="1"}checked{/eq}>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block text-right">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                <button class="layui-btn" lay-filter="submit-psw" lay-submit>修改</button>
            </div>
        </div>
    </form>

    <script type="text/javascript" src="/static/assets/libs/layui/layui.js"></script>
    <script type="text/javascript" src="/static/assets/js/common.js?v=312"></script>
    <script>
        layui.use(['layer', 'form', 'admin'], function () {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;
            var admin = layui.admin;

            admin.iframeAuto();  // 让当前iframe弹层高度适应

            // 监听提交
            form.on('submit(submit-psw)', function (data) {
                $.ajax({
                    type: "POST",                      //请求类型
                    url: "{:url('admin/question/sort_edit')}",//URL
                    data: data.field,   //传递的参数
                    dataType: "json",                 //返回的数据类型
                    success: function (data) {
                        if (data.code == 0) {
                            layer.open({
                                title: '添加提示',
                                content: '修改成功',
                                btn: ['确认'],
                                yes: function (index2, layero) {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                }
                            });

                        } else {
                            layer.alert('修改失败');
                        }
                    },
                    error: function (data) {
                        alert("请求失败");
                    }
                });
                return false;
            });

        });
    </script>
</body>

</html>